﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TeamCityMonitor.Attributes;
using TeamCityMonitor.Models;
using TeamCityMonitor.Properties;

namespace TeamCityMonitor.Controllers
{
    [DisableCaching]
    public class AdminController : Controller
    {
        private List<Setting> settings;

        public AdminController()
        {
            settings = new List<Setting>();

            foreach(SettingsProperty prop in Settings.Default.Properties)
            {
                settings.Add(new Setting {  Name = prop.Name, 
                                            Value = Settings.Default.PropertyValues[prop.Name].PropertyValue.ToString(),
                                            DefaultValue = prop.DefaultValue.ToString()
                                         });
            }

            settings = settings.OrderBy(setting => setting.Name).ToList();
        }

        [DisableCaching]
        public ActionResult Index()
        {
            return View(settings);
        }
    }
}
